unit Principal;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DBXMySQL, Vcl.Menus, Data.DB,
  Data.SqlExpr, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.Imaging.pngimage, Vcl.Buttons;

type
  TfrmPrincipal = class(TForm)
    Conexao: TSQLConnection;
    MenuPrincipal: TMainMenu;
    Arquivo1: TMenuItem;
    Usuarios1: TMenuItem;
    pnlPrincipal: TPanel;
    pnlRodape: TPanel;
    Label1: TLabel;
    lblNomeUsuario: TLabel;
    Membros1: TMenuItem;
    Image1: TImage;
    Revista1: TMenuItem;
    Sair1: TMenuItem;
    pnlMenuSuperior: TPanel;
    btnMembros: TSpeedButton;
    Aula1: TMenuItem;
    Classe1: TMenuItem;
    Escala1: TMenuItem;
    btnEscala: TSpeedButton;
    btnRevista: TSpeedButton;
    btnClasse: TSpeedButton;
    btnAula: TSpeedButton;
    btnUsuarios: TSpeedButton;
    btnSair: TBitBtn;
    procedure Usuarios1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Revista1Click(Sender: TObject);
    procedure Sair1Click(Sender: TObject);
    procedure Aula1Click(Sender: TObject);
    procedure Classe1Click(Sender: TObject);
    procedure Escala1Click(Sender: TObject);
    procedure btnEscalaClick(Sender: TObject);
    procedure btnClasseClick(Sender: TObject);
    procedure btnRevistaClick(Sender: TObject);
    procedure btnUsuariosClick(Sender: TObject);
    procedure btnAulaClick(Sender: TObject);
    procedure btnSairClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    function confirmarSaidaSistema: boolean;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmPrincipal: TfrmPrincipal;

implementation

uses
    Login, CadUsuario, CadRevista, CadAula, CadClasse, CadEscala;
{$R *.dfm}

procedure TfrmPrincipal.Aula1Click(Sender: TObject);
begin
    Application.CreateForm(TfrmCadAula, frmCadAula);
    frmCadAula.ShowModal;
    frmCadAula.Free;
end;

procedure TfrmPrincipal.btnEscalaClick(Sender: TObject);
begin
    Application.CreateForm(TfrmCadEscala, frmCadEscala);
    frmCadEscala.ShowModal;
    frmCadEscala.Free;
end;

procedure TfrmPrincipal.btnRevistaClick(Sender: TObject);
begin
    Application.CreateForm(TfrmCadRevista, frmCadRevista);
    frmCadRevista.ShowModal;
    frmCadRevista.Free;
end;

procedure TfrmPrincipal.btnSairClick(Sender: TObject);
begin
    if confirmarSaidaSistema then
        Application.Terminate;
end;

procedure TfrmPrincipal.btnUsuariosClick(Sender: TObject);
begin
    Application.CreateForm(TfrmCadUsuario, frmCadUsuario);
    frmCadUsuario.ShowModal;
    frmCadUsuario.Free;
end;

procedure TfrmPrincipal.btnAulaClick(Sender: TObject);
begin
    Application.CreateForm(TfrmCadAula, frmCadAula);
    frmCadAula.ShowModal;
    frmCadAula.Free;
end;

procedure TfrmPrincipal.btnClasseClick(Sender: TObject);
begin
    Application.CreateForm(TfrmCadClasse, frmCadClasse);
    frmCadClasse.ShowModal;
    frmCadClasse.Free;
end;

procedure TfrmPrincipal.Classe1Click(Sender: TObject);
begin
    Application.CreateForm(TfrmCadClasse, frmCadClasse);
    frmCadClasse.ShowModal;
    frmCadClasse.Free;
end;

procedure TfrmPrincipal.Escala1Click(Sender: TObject);
begin
    Application.CreateForm(TfrmCadEscala, frmCadEscala);
    frmCadEscala.ShowModal;
    frmCadEscala.Free;
end;

procedure TfrmPrincipal.FormClose(Sender: TObject; var Action: TCloseAction);
begin
    if confirmarSaidaSistema then
        Application.Terminate
    else
        Action := caNone;
end;

procedure TfrmPrincipal.FormShow(Sender: TObject);
begin
    {Application.CreateForm(TfrmLogin, frmLogin);
    frmLogin.ShowModal;
    frmLogin.Free;}
end;

procedure TfrmPrincipal.Revista1Click(Sender: TObject);
begin
    Application.CreateForm(TfrmCadRevista, frmCadRevista);
    frmCadRevista.ShowModal;
    frmCadRevista.Free;
end;

procedure TfrmPrincipal.Sair1Click(Sender: TObject);
begin
    if confirmarSaidaSistema then
        Application.Terminate;
end;

procedure TfrmPrincipal.Usuarios1Click(Sender: TObject);
begin
    Application.CreateForm(TfrmCadUsuario, frmCadUsuario);
    frmCadUsuario.ShowModal;
    frmCadUsuario.Free;
end;

function TfrmPrincipal.confirmarSaidaSistema: boolean;
begin
    if MessageDlg('Deseja realmente sair do sistema?', mtConfirmation, mbYesNo, 0) = mrYes then
        Result := True
    else
        Result := False;
end;

end.
